package demo.response;

import lombok.Data;

/**
 * @Author Admin
 * @date 2022/11/8 18:03
 * @Description TODO
 * @Version 1.0
 **/
@Data
public class Result {
    private int code;
    private String msg;
    private Object data;

    public static Result ok(Object data) {
        Result r = new Result();
        r.setCode(200);
        r.setMsg("成功");
        r.setData(data);
        return r;
    }

    public static Result ok() {
        return ok(null);
    }

    public static Result error(String msg) {
        Result r = new Result();
        r.setCode(500);
        r.setMsg(msg);
        r.setData(null);
        return r;
    }

    public static Result error() {
        return error("服务器错误");
    }
}
